#ifndef __SubMeshRenderGroup_H__
#define __SubMeshRenderGroup_H__

#include "d3dheaders.h"
#include "video/Array.h"
#include <vector>

namespace KEngine
{

class Material;
class Device;
class SubMeshRenderGroup
{
	typedef std::vector<DWORD> SubMeshVIList;

public:
	SubMeshRenderGroup(Device* device);
	virtual ~SubMeshRenderGroup();

	void setMtl(Material* mtl);
	Material* getMtl() const;
	void addVertexIndex(DWORD idx);

	void optimize();
	void render(int numVertex);

	void updateIndexBuffer(bool forceCreate = false);
	
protected:
	Material*				mMaterial;
	Array<DWORD>			mIndices;
	ID3DIndexBuffer*	mIndexBuffer;

	SubMeshVIList			mVIList;

	Device*					mDevice;
};

}

#endif